
//引入pinia
import { defineStore } from 'pinia'

//创建一个存储
export const useMoneyStore = defineStore('money', {
    state:()=>({money:100})   //存储数据
    ,
    getters:{      //属性计算
      usd:(state) => state.money * 7,
      rmb:(state) => state.money
    },
    actions:{      //修改
        pay(num){
            //this.money 指的事 state 里面的 属性
            this.money-=num;  //修改 money 添加
        },
        win(n){
            this.money+=n; //修改 money 减少
        }
    }
})
